<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>书籍信息</title>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <link rel="stylesheet" href="${pageContext.request.contextPath }/dist/css/bootstrap.min.css" type="text/css"></link>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/ie10-viewport-bug-workaround.css" type="text/css"></link>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/justified-nav.css" type="text/css"></link>
    <script type="text/javascript" src="${pageContext.request.contextPath }/assets/js/ie-emulation-modes-warning.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/css.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/jquery.pagination.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.pagination.min.js"></script>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }
        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
</head>
<body>
<div class="container">
      <div class="masthead">
        <h3 class="text-muted">智能图书管理系统</h3>
        <nav>
          <ul class="nav nav-justified">
            <li class="active"><a href="<%=request.getContextPath()%>/user/show">图书查询</a></li>
            <li ><a href="<%=request.getContextPath()%>/user/back">借阅查询</a></li>
            <li><a href="<%=request.getContextPath()%>/user/showBackBook">图书归还或评分</a></li>
            <li><a href="<%=request.getContextPath()%>/user/showReserveBook">预约查询</a></li>
            <li><a href="<%=request.getContextPath()%>/user/person">个人信息</a></li>
            <li><a href="<%=request.getContextPath()%>/quit">退出登录</a></li>
          </ul>
        </nav>
      </div>
    

 
 <div class="container">
 
 
  
   <form action="${pageContext.request.contextPath }/user/insert" method="post"align="center">
   <h2>本书的信息如下：</h2>
    <input type="hidden" name="bid" value="${book.id}" />
     <div class="container"  style="float:left; width:25%">   
     <img src="../bookimg/${book.id}.jpg" style="width:200px;height:300px"/>
     </div>
     <div style="float:left; width:75%">   
    <table class="table table-bordered table-hover definewidth m10" >
        <tr>
        	
            <td width="10%" class="tableleft">书籍类别</td>
            <td><input type="text" name="sname" value="${book.sname}" disabled="disabled"/></td>
        </tr>
        <tr>
            <td class="tableleft">书籍名称</td>
            
            <td>
            
            <input type="text" name="bname" value="${book.bname}" disabled="disabled"/>
            </td>
        </tr>
        <tr>
            <td class="tableleft">作者</td>
            <td><input type="text" name="author" value="${book.author}" disabled="disabled"/></td>
        </tr>
        <tr>
            <td class="tableleft">出版社</td>
            <td><input type="text" name="birth" value="${book.birth}" disabled="disabled"/></td>
        </tr>
        <tr>
             <td class="tableleft">版本</td>
            <td><input type="text" name="edition" value="${book.edition}" disabled="disabled"/></td>
        </tr>
        <tr>
              <td class="tableleft">剩余数量</td>
            <td><input type="text" name="number" value="${book.number}" disabled="disabled"/></td>
        </tr>
        <tr>
            <td class="tableleft"></td>
            <td>
           <c:if test="${book.number>0}">
           			<button type="submit" class="btn btn-primary" type="button">确认借阅</button>	&nbsp;&nbsp;<a type="button" class="btn btn-success" name="backid" id="backid" href="<%=request.getContextPath()%>/user/show">返回列表</a>
           </c:if>
            <c:if test="${book.number<=0}">
           		<a type="submit" class="btn btn-primary" type="button" href="<%=request.getContextPath()%>/user/reserve?bkid=${book.id}">预定</a>	&nbsp;&nbsp;<a type="button" class="btn btn-success" name="backid" id="backid" href="<%=request.getContextPath()%>/user/show">返回列表</a>
           </c:if>
            
            </td>
        </tr>
    </table>
    </div>
   
</form>
<h3>读者评论区</h3>
 <c:forEach items="${list}" var="bookrating">
				<hr align=center width=100% color=#987cb9 SIZE=3 />
				<tr>
				  <td><a href="javascript:void(0)"  onclick="checkFunction()" style="font-size:20px">${bookrating.userid}号用户</a></td>
					<td>
					 <div id="starRating">
                      <span class="photo">
                      <c:if test="${bookrating.rating==1}">
                        <span><i class="halfhigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==2}">
                        <span><i class="high"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==3}">
                        <span><i class="high"></i></span>
                        <span><i class="halfhigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==4}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==5}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="halfhigh"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==6}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="nohigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==7}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="halfhigh"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==8}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="nohigh"></i></span>
                      </c:if>
                      <c:if test="${bookrating.rating==9}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="halfhigh"></i></span>
                      </c:if>
                       <c:if test="${bookrating.rating==10}">
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                        <span><i class="high"></i></span>
                      </c:if>
                       <a style="color:red; font-size:20px" >${bookrating.rating}分</a>
                     </span>
                    </div>
                   </td>
					<td>
					 <h4>${bookrating.comments}</h4><br/> 
					 <a href="javascript:void(0)" onclick="upFunction('<%=request.getContextPath()%>/user/clickUp?bkid=${bookrating.bookid}&uid=${bookrating.userid}')">
					                                                  评的好👍(<text id="0${bookrating.bookid}${bookrating.userid}">${bookrating.up}</text>)</a>  
					 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					 <a href="javascript:void(0)" onclick="downFunction('<%=request.getContextPath()%>/user/clickDown?bkid=${bookrating.bookid}&uid=${bookrating.userid}')">
					 评的不客观👎(<text id="1${bookrating.bookid}${bookrating.userid}">${bookrating.down}</text>)</a>
					</td>
				</tr>
				
	</c:forEach>
</div>



 <!-- Site footer -->
      <footer class="footer" align="center">
        <p>YanJiaDou &copy; 2020 版权所有</p>
      </footer>

</div>
</body>
</html>
<script>
    $(function () {       
		$('#backid').click(function(){
				window.location.href="{:U('User/index')}";
		 });

    });
   
</script>
 <script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url,cfunc)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}

//点赞ajax函数
function upFunction(url)
{
  loadXMLDoc(url,function()
  {
	var numArr = url.match(/\d+/g);

	var id=0+numArr[0]+numArr[1];
	//alert(id);

    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(id).innerHTML=xmlhttp.responseText;
    }
  
  });
}
//点踩ajax函数
function downFunction(url)
{
  loadXMLDoc(url,function()
  {
	var numArr = url.match(/\d+/g);

	var id=1+numArr[0]+numArr[1];
	//alert(id);

    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(id).innerHTML=xmlhttp.responseText;
    }
  
  });
}

</script>